package com.luyuan.crm.member.web.provider;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.faces.model.SelectItem;

import org.springframework.stereotype.Component;

import com.luyuan.crm.member.model.Region;
import com.luyuan.crm.member.service.RegionService;
import com.ruijie.web.jsf.provider.SelectItemsProvider;

@Component("provinceProvider")
public class ProvinceProvider implements SelectItemsProvider {

    @Resource(name = "regionService")
    private RegionService regionService;

    @Override
    public List<SelectItem> getSelectItems(Object... parameters) {
        List<SelectItem> items = new ArrayList<SelectItem>();

        List<Region> regions = regionService.loadProvince();
        for (Region region : regions) {
            SelectItem item = new SelectItem(region.getProvince(), region.getProvince());

            items.add(item);
        }

        return items;
    }

}
